package com.itheima.edu.day24CountDownLatch;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo {
    public static void main(String[] args) {
        CountDownLatch cdl = new CountDownLatch(3);
        //底层原理：
        /*
        * 底层是一个计数器
        * 每次countDown（）方法调用时，计数器-1
        *  await（）让线程等待，当计数器为0时，唤醒线程
        * */

        Mather mm = new Mather(cdl);
        mm.start();

        Kid1 k1 = new Kid1(cdl);
        k1.setName("小明");
        k1.start();

        Kid2 k2 = new Kid2(cdl);
        k2.setName("小红");
        k2.start();

        Kid3 k3 = new Kid3(cdl);
        k3.setName("小花");
        k3.start();


    }
}
